<style lang="scss" scoped>
  @import '../../../styles/common/loading.less';
  .container{
    border: none !important;
    margin-top: 4px;
  }
  .el-col-offset-1 {
    margin-left: 0%;
  }
  .button_a {
    background-color: rgba(255, 138, 0, 1);
    border-color: rgba(255, 138, 0, 1);

  }
  .col_a {
    margin-left: 2%;
  }
  .el-card {
    height: 200px;
  }

  .el-button--primary {
    background-color: rgba(255, 138, 0, 1);
    border-color: rgba(255, 138, 0, 1);
  }
</style>
<template>
  <div  class="common-background-color">
    <div style="width:98%;height:100%;margin: 6px 12px;">
      <el-collapse v-model="activeNames" v-if="this.item===1||this.item===0"  >
        <el-collapse-item title="年度费用累计维护信息"  name="1">
          <el-form :model="form" :rules="rules" ref="form" class="info-submit-form">
            <el-row type="flex" >
              <el-col :span="8">
                <el-form-item prop="insuredName" label="姓名" >
                  <el-input  v-model="form.insuredName"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8" >
                <el-form-item prop="documentNo" label="证件号"  >
                  <el-input  v-model="form.documentNo">
                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8" >
                <el-form-item prop="socialSecurityNo" label="社/医保号"  >
                  <el-input  v-model="form.socialSecurityNo">
                  </el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">

              <el-col :span="8" >
                <el-form-item prop="year" label="年度" >
                  <el-input  v-model="form.year"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8" >
                <el-form-item prop="hospNumTotal" label="住院次数累计" >
                  <el-input  v-model="form.hospNumTotal"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8" >
                <el-form-item prop="medFeeTotal" label="医疗费用累计" >
                  <el-input  v-model="form.medFeeTotal"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">

              <el-col :span="8">
                <el-form-item prop="overallPayTotal" label="统筹支付累计" >
                  <el-input  v-model="form.overallPayTotal"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8" >
                <el-form-item prop="basicMedAmount" label="符合基本医疗" >
                  <el-input  v-model="form.basicMedAmount"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8" >
                <el-form-item prop="largePayTotal" label="大额支付累计" >
                  <el-input  v-model="form.largePayTotal"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">

              <el-col :span="8">
                <el-form-item prop="enterOveralTotal" label="进入统筹累计" >
                  <el-input  v-model="form.enterOveralTotal"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8" >
                <el-form-item prop="insuDeductibleTotal" label="起付标准累计" >
                  <el-input  v-model="form.insuDeductibleTotal"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8" >
                <el-form-item prop="enterIINesslTotal" label="进入大病累计" >
                  <el-input  v-model="form.enterIINesslTotal"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </el-collapse-item>
      </el-collapse>
      <el-collapse v-model="activeNames" v-if="this.item===2">
        <el-collapse-item title="年度费用累计维护信息"  name="1">
          <el-form :model="form" label-width="110px">
            <el-row type="flex" >
              <el-col :span="8">
                <el-form-item label="姓名" >
                  <el-input disabled  v-model="form.insuredName"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8" >
                <el-form-item label="证件号"  >
                  <el-input disabled  v-model="form.documentNo"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8" >
                <el-form-item label="社/医保号"  >
                  <el-input disabled  v-model="form.socialSecurityNo">
                  </el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">

              <el-col :span="8" >
                <el-form-item label="年度" >
                  <el-input disabled  v-model="form.year"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8" >
                <el-form-item label="住院次数累计" >
                  <el-input disabled  v-model="form.hospNumTotal"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8" >
                <el-form-item label="医疗费用累计" >
                  <el-input disabled  v-model="form.medFeeTotal"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">

              <el-col :span="8">
                <el-form-item label="统筹支付累计" >
                  <el-input disabled  v-model="form.overallPayTotal"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8" >
                <el-form-item label="符合基本医疗" >
                  <el-input disabled  v-model="form.basicMedAmount"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8" >
                <el-form-item label="大额支付累计" >
                  <el-input disabled  v-model="form.largePayTotal"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex">
              <el-col :span="8">
                <el-form-item label="进入统筹累计" >
                  <el-input disabled  v-model="form.enterOveralTotal"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8" >
                <el-form-item label="起付标准累计" >
                  <el-input disabled  v-model="form.insuDeductibleTotal"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="8" >
                <el-form-item label="进入大病累计" >
                  <el-input disabled  v-model="form.enterIINesslTotal"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </el-collapse-item>
      </el-collapse>
    </div>
    <div>
      <template>
        <div slot="footer" style="text-align: center;height: 60px;line-height: 30px" class="dialog-footer">
          <el-button type="primary" v-if="this.item===0" @click="save('form')">保 存</el-button>
          <el-button type="primary" v-if="this.item===1" @click="handleEditUpdate('form')">修 改</el-button>
          <el-button type="primary" v-if="this.item===0" @click="resetForm('form')">重 置</el-button>
          <el-button type="primary" v-if="this.item===1||this.item===2" @click="fanhui">关 闭</el-button>
        </div>
      </template>
    </div>
    <el-dialog
      :visible.sync="Successdialog"
      :show-close="false"
      :close-on-click-modal="true"
      :close-on-press-escape="false"
      width="20%"
      center>
      <div style="margin-top: -35px;">
        <div>| 年度费用累计维护</div>
        <hr style="width: 80%;margin-left: 1px">
      </div>
      <div v-if="this.item1===0" style="text-align: center;margin-top: 20px">
        <img src="../../../assets/images/pass.png" width="60">
        <div style="margin-top: 10px">{{this.message}}</div>
        <!--        <div style="margin-top: 10px">大病赔案号：{{formInline.caseNo}}</div>-->
      </div>
      <div v-if="this.item1===1" style="text-align: center;margin-top: 20px">
        <img src="../../../assets/images/notPass.png" width="60">
        <div style="margin-top: 10px">提交失败</div>
        <!--        <div style="margin-top: 10px">大病赔案号：{{formInline.caseNo}}</div>-->
      </div>
      <div style="margin-top: 15px;text-align: center"><span style="font-size: x-large">{{time}}</span>秒后跳转到上一个页面</div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="researchCheckSearch" type="text" :disabled="isDisabled">关闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import * as api from '@/api/basicInformation'
import * as api1 from '@/api/baseDate'
export default {
    name: 'researchTask',
    inject:['reload'],
    data() {
      return {
        rules:{ // 终止日期不能早于开始日期
          insuredName:[{ required: true, message: '姓名不能为空', trigger: 'blur' },],
          documentNo:[{ required: true, message: '证件号不能为空', trigger: 'blur' },],
          year:[{ required: true, message: '年度不能为空', trigger: 'blur' },],
        },
        Successdialog:false,
        query: {
          address: '',
          name: '',
          pageIndex: 1,
          pageSize: 10
        },
        activeNames: ['1','2'],
        //控制显示隐藏
        isBase:false,
        isSurvey:false,
        shenheyijian:"1",
        activeName: 'first',
        multipleSelection: [],
        delList: [],
        editVisible: false,
        pageTotal: 0,
        form: {
        },
        idx: -1,
        id: -1,
        formInline: {
          policy: '20143301000000008',
          startDate: '2019-01-01',
          endDate: '2022-01-01',
          insurePlan: '徐州医保局',
        },
        researchHistory:[
          {
            taskno:"20210721001",
            handlerOrg:"江苏省徐州",
            handler:"李刚",
            submitTime:'2021-01-01',
            surveyPass:'调查中',
            surveyResult:'通过无误',
            surveyVerdict:'可以提交审核'
          }
        ],
        message:'',
        time:0,
        item:0,
        item1:0,
        drugCatalog:[
          {comCode: "20000000000",comName:"总公司"},
          {comCode: "20020000000",comName:"江苏分公司"},
          {comCode: "20020100000",comName:"徐州中支公司"},
        ],
      };
    },
    created() {
      this.form=JSON.parse(this.$route.query.yearCostMaintainDemo)
      this.item=JSON.parse(this.$route.query.item)
      console.log("123"+this.list)
    },
    mounted() {
      this.restaurants=this.drugCatalog.map(item=>{
        return{
          code:item.comCode,
          value:item.comName,
        }
      })
    },
    methods: {
      delFlagFormat(row, column) {
        let delFlag = row.delFlag
        if (delFlag === 0) {
          return '无效'
        } else if (delFlag === 1) {
          return '有效'
        }
      },
      querySearchAsync(queryString, cb) {
        var restaurants = this.restaurants;
        var results = queryString ? restaurants.filter(this.createStateFilter(queryString)) : restaurants;

        clearTimeout(this.timeout);
        this.timeout = setTimeout(() => {
          cb(results);
        }, 1000 * Math.random());
      },
      createStateFilter(queryString) {
        return (state) => {
          // return (state.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
          return (state.value.toLowerCase().indexOf(queryString.toLowerCase()) > -1);
        };
      },
      comCode(comName){
        this.drugCatalog.forEach(item=>
          {
            if(comName===item.comName){
              this.form.comCode=item.comCode
            }
          }
        )
      },
      save(formName){
        this.$refs[formName].validate((valid) => {
          if (valid) {
            api.getSaveChargeTotal(this.form
            ).then(res => {
              this.message=res.data.resultMsg;
              this.Successdialog=true
              // 把time改为5
              this.time = 5;
              // 设定一个定时器，每一秒调用一次coundDown方法，time-1
              setInterval(this.countDown, 1000);
            }).catch((function () {
                /*let THIS = this;*/
                this.item1=1,
                  this.Successdialog=true
                // 把time改为5
                this.time = 5;
                // 设定一个定时器，每一秒调用一次coundDown方法，time-1
                setInterval(this.countDown, 1000);
              }),
            )
          } else {
            console.log('error submit!!');
            return false;
          }
        });

      },
      handleEditUpdate(formName){
        this.$refs[formName].validate((valid) => {
          if (valid) {
            api.getUpdataChargeTotal(this.form
            ).then(res => {
              this.message=res.data.resultMsg;
              this.Successdialog=true
              // 把time改为5
              this.time = 5;
              // 设定一个定时器，每一秒调用一次coundDown方法，time-1
              setInterval(this.countDown, 1000);
            }).catch((function () {
                /*let THIS = this;*/
                this.item1=1,
                  this.Successdialog=true
                // 把time改为5
                this.time = 5;
                // 设定一个定时器，每一秒调用一次coundDown方法，time-1
                setInterval(this.countDown, 1000);
              }),
            )
          } else {
            console.log('error submit!!');
            return false;
          }
        });

      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
        this.reload();
      },
      fanhui(){
          //this.$router.go(-1)
          this.closePageTo(this.$store,this.$route,this.$router,'yearCostMaintain');
      },
      isBaseInfo(){
        this.isBase=!this.isBase;
      },
      surveyHistory(){
        this.isSurvey=!this.isSurvey;
      },
      // 分页导航
      handlePageChange(val) {
        this.$set(this.query, 'pageIndex', val);
        this.getData();
      },
      onSubmit() {
        console.log('submit!');
      },
      researchCheckSearch(){
        // this.Successdialog=false
        //this.$router.push({name:'yearCostMaintain'});
        this.closePageTo(this.$store,this.$route,this.$router,'yearCostMaintain');
        self.close();
      },
//   封装一个方法
      countDown() {
        let THIS = this;
        THIS.time--;
      },
    },
    watch: {
      //   监听time的值
      time: function (newVal) {
        if (newVal === 0) {
          //this.$router.push({name:'yearCostMaintain'});
          this.closePageTo(this.$store,this.$route,this.$router,'yearCostMaintain');
          self.close();
          // this.Successdialog=false
        }
      },
    },
  };
</script>